﻿using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using SZSLSystem.Model;
namespace SZSLSystem.BLL
{
	/// <summary>
	///业务逻辑类 Buyer (create by HC 2013/1/14 22:28:41)
	/// </summary>
	public class Buyer
	{
		private readonly SZSLSystem.DAL.Buyer dal=new SZSLSystem.DAL.Buyer();
		public Buyer(){}
		public bool Exists(string OID)
		{
			 return dal.Exists(OID);
		}

		public int Delete(string OID)
		{
			 return dal.Delete(OID);
		}

		public int Add(SZSLSystem.Model.Buyer model)
		{
			 return dal.Add(model);
		}

		public SZSLSystem.Model.Buyer GetModel(string OID)
		{
			 return dal.GetModel(OID);
		}

		public int Update(SZSLSystem.Model.Buyer model)
		{
			 return dal.Update(model);
		}

		public DataSet GetList(string strWhere)
		{
			 return dal.GetList(strWhere);
		}

		public DataSet GetList(int Top,string strWhere,string fieldOrder)
		{
			 return dal.GetList(Top,strWhere,fieldOrder);
		}

		public DataSet GetList(string showFields,string strWhere)
		{
			 return dal.GetList(showFields,strWhere);
		}

		public List<SZSLSystem.Model.Buyer> GetModelList(string strWhere)
		{
			 DataSet ds = dal.GetList(strWhere);
			 return DataTableToList(ds.Tables[0]);
		}

		public List<SZSLSystem.Model.Buyer> DataTableToList(DataTable dt)
		{
			List<SZSLSystem.Model.Buyer> modelList = new List<SZSLSystem.Model.Buyer>();
			if (dt.Rows.Count > 0)
			{
				SZSLSystem.Model.Buyer model;
				foreach (DataRow row in dt.Rows)
				{
					model = new SZSLSystem.Model.Buyer();
					model.OID=row["OID"].ToString();
					model.BuyerName=row["BuyerName"].ToString();
					model.CredentialsType=row["CredentialsType"].ToString();
					model.CredentialsNumber=row["CredentialsNumber"].ToString();
					model.Sex=row["Sex"].ToString();
					model.Birthday=row["Birthday"].ToString();
					model.Mobile=row["Mobile"].ToString();
					model.Telphone=row["Telphone"].ToString();
					model.PostalAddress=row["PostalAddress"].ToString();
					model.PostalCode=row["PostalCode"].ToString();
					modelList.Add(model);
				}
			}
			return modelList;
		}

		public object GetSingle(string fieldName,string strWhere)
		{
			 return dal.GetSingle(fieldName,strWhere);
		}
	}
}